package com.spzx.product.controller;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.domain.R;
import com.spzx.common.security.annotation.InnerAuth;
import com.spzx.product.api.domain.SkuLockVo;
import com.spzx.product.service.ISkuStockService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.spzx.common.core.web.controller.BaseController;

import java.util.List;

/**
 * <p>
 * 商品sku库存表 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2024-12-20
 */
@RestController
@RequestMapping("/skuStock")
public class SkuStockController extends BaseController {

    @Autowired
    private ISkuStockService stockService;

    @InnerAuth
    @Operation(summary = "检查库存并锁定库存")
    @PostMapping("/checkAndLock/{orderNo}")
    public R<String> checkAndLock(
            @Parameter(description = "订单号")
            @PathVariable String orderNo,
            @Parameter(description = "商品sku库存列表")
            @RequestBody List<SkuLockVo> skuLockVoList){
        return R.ok(stockService.checkAndLock(orderNo, skuLockVoList));
    }
}
